#[allow(dead_code)]
#[allow(dead_code)]
#[allow(dead_code)]
fn hello() {
    println!("hello world");
}

#[allow(dead_code)]
pub fn test03() {
    // fn() 函数指针类型
    // 需要显示指定函数指针类型
    let fn_ptr: fn() = hello;
    println!("{:p}", fn_ptr);
    let other_ptr = fn_ptr;
    println!("{:p}", other_ptr);
    fn_ptr();
}

#[allow(dead_code)]
#[derive(Debug, PartialEq)]
struct Student {
    name: &'static str,
    score: i32,
}

#[allow(dead_code)]
#[allow(unused_variables)]
impl Student {
    pub fn new(name: &'static str, score: i32) -> Self {
        Student { name, score }
    }
    pub fn get_name(&self) -> &str {
        self.name
    }

    pub fn set_name(&mut self, name: &'static str) {
        self.name = name;
    }

    pub fn get_score(&self) -> i32 {
        self.score
    }

    pub fn set_score(&mut self, score: i32) {
        self.score = score;
    }
}

#[allow(dead_code)]
pub fn test02() {
    let mut stu = Student::new("zhangsan", 22);
    println!("{:?}", stu);

    // 修改stu字段
    stu.set_score(23);
    stu.set_name("lisi");
    println!("{:?}", stu);
}

#[allow(dead_code)]
pub fn test01() {
    let a = 2;
    let b = 3;

    let r = add(a, b);
    println!("{a} + {b}={}", r);
}

fn add(a: i32, b: i32) -> i32 {
    a + b // return a + b;
}